From 8bff726e38f99d160c8c779782cb86d5fe3b5950 Mon Sep 17 00:00:00 2001 From: Mikko Perttunen Date: Mon, 2 Mar 2015 00:53:46 +0200 Subject: [PATCH] Disable LTO for host (plugin, build script) builds When building host code, -C prefer-dynamic is passed, but that option is mutually exclusive with -C lto. Thus when LTO is specified, rustc errors out. --- src/cargo/ops/cargo_rustc/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 3608429ab..569fa6781 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -587,7 +587,12 @@ fn build_base_args(cx: &Context, if profile.opt_level() != 0 { cmd.arg("-C").arg(&format!("opt-level={}", profile.opt_level())); } - if (target.is_bin() || target.is_staticlib()) && profile.lto() { + + // Disable LTO for host builds as prefer_dynamic and it are mutually + // exclusive. + let lto = (target.is_bin() || target.is_staticlib()) && profile.lto() && + !profile.is_for_host(); + if lto { cmd.args(&["-C", "lto"]); } else { // There are some restrictions with LTO and codegen-units, so we -- 2.30.2